package com.zzl.study.demo.controller;

import com.zzl.study.demo.utils.ZoneUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 时间工具Controller
 *
 * @author: zhangzl
 * @date: 2025/10/20 15:51
 * @version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/time")
public class TimeController {

    /**
     * 获取指定时区的时间
     *
     * @param timeZoneId 时区ID
     * @return 指定时区的时间
     */
    @GetMapping("/city")
    public String getCityTimeMethod(@RequestParam("timeZoneId") String timeZoneId) {
        log.info("The current time zone is {}", timeZoneId);
        return String.format("The current time zone is %s and the current time is %s", timeZoneId, ZoneUtils.getTimeByZoneId(timeZoneId));
    }

}
